﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace QD.Entity
{
    public interface IDbEntity<T>
    {
        object __get_data(int fieldIndex);
        void __init_from_db(ModelDataReader r);
        object __get_primary_key();
        void __set_primary_key(object value);
        Int32 __get_primary_idx();
    }

    public class DbEntity
    {
        const int ENTITY_PROPERTIES_LENGTH = 64;
        protected BitArray __bit_flag = new BitArray(ENTITY_PROPERTIES_LENGTH, false);
        public void __reset()
        {
            for (int i = 0; i < __bit_flag.Length; ++i)
                __bit_flag[i] = false;
        }
        public bool __get_bit(int index) { return __bit_flag[index]; }
        protected void __bit_change(int at) { __bit_flag[at] = true; }
        public virtual object __get_data(int fieldIndex) { throw new NotImplementedException(); }
        public virtual object __get_primary_key() { return __get_data(__get_primary_idx()); }
        public virtual int __get_primary_idx() { return 0; }
        public virtual void __set_primary_key(object value) {  }
        public DbEntity()
        {
        }
    }
}
